home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Sample Code / Video Digitizer / Easy Video Grabber / EasyGrabberTest.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-06  |  1.8 KB  |  105 lines  |  [TEXT/MPS ]

  1. /*
  2.   File:            EasyGrabberTest.c
  3.   Contains:        Test Application for the Video Grabber Functions.
  4.   Written by:    David Van Brink / QT Engineering
  5.   Copyright:    © 1991-1994 by Apple Computer, Inc., all rights reserved.
  6.   Change History (most recent first):
  7.   <2>         12/4/94        khs        changed the format of the file to the new look and feel
  8.   <1>         12/18/91    dvb        1.0 Started
  9.   To Do:
  10. */
  11.  
  12.  
  13. // INCLUDES
  14. #include <QuickDraw.h>
  15. #include <Events.h>
  16. #include <Menus.h>
  17. #include <ToolUtils.h>
  18. #include <Menus.h>
  19. #include <Windows.h>
  20. #include <Memory.h>
  21. #include <Fonts.h>
  22. #include <OSEvents.h>
  23.  
  24. #include <Movies.h>
  25.  
  26. #include "BigEasyVideoGrabber.h"
  27.  
  28. // FUNCTION PROTOTYPES
  29. static void InitToolbox(void);
  30. static void DigitizeInAWindow(void);
  31.  
  32.  
  33. // FUNCTIONS
  34. void InitToolbox(void)
  35. {
  36.     InitGraf(&qd.thePort);
  37.     InitFonts();
  38.     FlushEvents(0xffff, 0);
  39.     InitWindows();
  40.     InitMenus();
  41.     InitCursor();
  42.  
  43.     EnterMovies();
  44. }
  45.  
  46.  
  47. void DigitizeInAWindow(void)
  48. {
  49.     WindowPtr w;
  50.     Rect r;
  51.     short i;
  52.     Boolean gotAFrame;
  53.  
  54.     SetRect(&r, 100, 100, 260, 220);            /* 160 x 120 window */
  55.  
  56.     w = NewCWindow(0, &r, "\pFive Clicks", true, noGrowDocProc, (WindowPtr) - 1, 0, 0);
  57.  
  58.     SetPort(w);
  59.  
  60.     /*
  61.      * Set the rectangle we'll be drawing into.
  62.      */
  63.     SetRect(&r, 0, 0, 160, 120);
  64.  
  65.     /*
  66.      * Let the user click five times
  67.      * and grab a frame each time.
  68.      *
  69.      * This is a substandard user interface,
  70.      * I am sure you will agree.
  71.      */
  72.     for (i = 0; i < 5; i++)
  73.     {
  74.         /*
  75.          * Wait For A MouseClick
  76.          */
  77.         while (!Button())
  78.             ;
  79.         while (Button())
  80.             ;
  81.  
  82.         /*
  83.          * Grab a frame, allocate and deallocate on the fly.
  84.          */
  85.         gotAFrame = GrabEasyVideoGrabber(nil, &r);
  86.  
  87.         /*
  88.          * If we didn't get a frame, just quit and go home.
  89.          */
  90.         if (!gotAFrame)
  91.             return;
  92.     }
  93. }
  94.  
  95.  
  96. // MAIN
  97. void main(void)
  98. {
  99.     InitToolbox();
  100.     DigitizeInAWindow();
  101.     FlushEvents(0xffff, 0);
  102. }
  103.  
  104.  
  105.